﻿
Imports elpmis

Public MustInherit Class _requestProcessor
    Inherits requestProcessor

    Private path As String = Nothing

    Protected MustOverride Function app() As lpmsmonitor

    Public NotOverridable Overrides Sub initial(Optional ByVal config As configParser = Nothing)
        MyBase.initial(config)
    End Sub

    Public NotOverridable Overrides Function pathidentity() As String
        Dim rtn As String = Nothing
        If lpmsmonitor.invokepath(app(), rtn) Then
            Return rtn
        Else
            Return path
        End If
    End Function

    Public NotOverridable Overrides Function process(ByVal context As httpContext) As Boolean
#If RETIRED Then
        If Not lpmsmonitor.invokeprocess(app()) Then
            Return False
        End If
        lpmsmonitor.invokeheader(app(), context)
        Return True
#End If
        Return lpmsmonitor.invokeprocess(app())
    End Function

    Public Sub New(ByVal path As String)
        MyBase.new()
        copy(Me.path, path)
    End Sub
End Class

Public Class nameRequestProcessor
    Inherits _requestProcessor

    Private name As String = Nothing

    Public Sub New(ByVal name As String, ByVal path As String)
        MyBase.New(path)
        copy(Me.name, name)
    End Sub

    Protected Overrides Function app() As lpmsmonitor
        Return findlpmsengine(name)
    End Function
End Class

Public Class scriptRequestProcessor
    Inherits _requestProcessor

    Private script As String = Nothing

    Public Sub New(ByVal path As String, ByVal script As String)
        MyBase.New(path)
        copy(Me.script, script)
    End Sub

    Protected Overrides Function app() As lpmsmonitor
        Return lpmsengine(script)
    End Function
End Class